package tt.dz.biz.service.financial;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import tt.dz.biz.dao.financial.ChannelBankAccountDAO;
import tt.dz.common.LogUtil;
import tt.dz.vo.ChannelBankaccountVO;

@Service("channelBankAccountService")
public class ChannelBankAccountService
{
  @Resource(name="channelBankAccountDAO")
  private ChannelBankAccountDAO channelBankAccountDAO;
  
  public List<ChannelBankaccountVO> listAllChannelSubject()
  {
    List<ChannelBankaccountVO> channelBankaccountList = null;
    try
    {
      channelBankaccountList = this.channelBankAccountDAO.listAllChannelSubject();
    }
    catch (Exception e)
    {
      LogUtil.error("查询渠道对应银行科目下的二级账户异常", e);
      channelBankaccountList = new ArrayList();
    }
    return channelBankaccountList;
  }
  
  public boolean insertChannelSubject(ChannelBankaccountVO channelBankaccountVO)
  {
    boolean excuteFlag = false;
    try
    {
      int i = this.channelBankAccountDAO.insertChannelSubject(channelBankaccountVO);
      excuteFlag = i > 0;
    }
    catch (Exception e)
    {
      LogUtil.error("插入渠道对应银行科目下的二级账户异常--入参：" + channelBankaccountVO.toString(), e);
      excuteFlag = false;
    }
    return excuteFlag;
  }
  
  public boolean updateChannelSubject(ChannelBankaccountVO channelBankaccountVO)
  {
    boolean excuteFlag = false;
    try
    {
      int i = this.channelBankAccountDAO.updateChannelSubject(channelBankaccountVO);
      excuteFlag = i > 0;
    }
    catch (Exception e)
    {
      LogUtil.error("更新渠道对应银行科目下的二级账户异常--入参：" + channelBankaccountVO.toString(), e);
      excuteFlag = false;
    }
    return excuteFlag;
  }
  
  public List<ChannelBankaccountVO> queryChannelBankAccountBychannelCode(String channelCode)
    throws Exception
  {
    try
    {
      return this.channelBankAccountDAO.queryChannelBankAccountBychannelCode(channelCode);
    }
    catch (Exception e)
    {
      LogUtil.error("通过渠道号查询对应科目异常，参数为：channelCode=" + channelCode, e);
      throw e;
    }
  }
}
